#ifndef CTRACKERWINDOW_H_
#define CTRACKERWINDOW_H_

#include <buola/gui/containers/cmosaiccontainer.h>

#include <buola/scene.h>
#include <buola/scene/csceneview.h>
#include <buola/scene/geodes/cpointcloud.h>
#include <buola/widgets/cimagebox.h>
#include <buola/gui/containers/clistcontainer.h>
#include <buola/widgets/cnumbox.h>
#include <buola/widgets/ccheckbox.h>
#include <buola/cv/cvisualservoing.h>
#include <buola/cv/io/ckinect.h>

#include <robot/kuka/cvirtualarm.h>
#include <robot/sdh/cvirtualhand.h>
#include <robot/nao/cvirtualnao.h>

namespace buola { namespace tracker {

class CTrackerWindow : public gui::CMosaicContainer
{
public:
    CTrackerWindow();
    virtual ~CTrackerWindow();

private:
    void SetupScene();
    void SetupCamera();
    void SetupViews();
    void SetupInput();
    void UpdateScene();
    
    void NextIteration(bool pReally=true,int pCount=1);

    void OnCoordsBox(int i);
    void OnCapture(const img::CImage_rgb8 &pRGB,const img::CImage_gray32f &pDepth);
    void SaveTracking();
    
private:
    gui::PToolBar mToolBar;
    
    CTimer mTimer;
    
    img::CImage_rgb8 mTargetImage;
    img::CImage_bgra8 mDirectionsImage;
    img::CImage_rgb8 mInputImage;
    
    cvi::CVisualServoing mVVS;
    
    robot::nao::CVirtualNao mVirtualNao;
//    robot::kuka::CVirtualArm mVirtualArm;
    
    scene::PScene mScene;
    scene::PRTTransform mVVSTransform;
    scene::PPerspectiveCamera mCamera;
        
    scene::PSceneView mSceneView;
    scene::PPointCloud mSceneCloud;
    gui::PImageBox mImageBox[3];
    
    gui::PListContainer mNumbersBox;
    gui::PNumBox mCoordsBox[6];

    std::unique_ptr<cvi::CKinect> mKinect;
    
    bool mRecording;
    int mFrameNumber=100000;
    int mSaveIndex=10000;
};

/*namespace tracker*/ } /*namespace buola*/ }

#endif /* CSERVOWINDOW_H_ */
